package com.op.studyingliteapp.activity.homeactivity;

import java.util.ArrayList;

import com.op.studyingliteapp.R;
import com.op.studyingliteapp.fragment.seminar.SeminarData;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
 * @author  kim 
 * @time by 2015.7.26
 */
public class SidebarAdapter extends BaseAdapter{
	private Context mContext;
	private ArrayList<SidebarData> Sidebarlsitview;
	/**
	 * @param mContext  
	 * @param Sidebarlsitview
	 */
	public SidebarAdapter(Context mContext,ArrayList<SidebarData> Sidebarlsitview){
		this.mContext=mContext;
		this.Sidebarlsitview=Sidebarlsitview;
	}
	
	public Context getmContext() {
		return mContext;
	}

	public void setmContext(Context mContext) {
		this.mContext = mContext;
	}
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return Sidebarlsitview.size();
	}

	@Override
	public SidebarData getItem(int position) {
		// TODO Auto-generated method stub
		return Sidebarlsitview.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LinearLayout linearLayout = null;
		if (convertView != null) {
			linearLayout = (LinearLayout) convertView;
		} else {
			linearLayout = (LinearLayout) LayoutInflater.from(getmContext()).inflate(R.layout.item_sidebar, parent, false);
		}
		
		final SidebarData data = getItem(position);
		
		ImageView Picture= (ImageView) linearLayout.findViewById(R.id.Picture);	
		TextView word = (TextView) linearLayout.findViewById(R.id.word);
		word.setText(data.getWord());
		Picture.setBackgroundResource(data.getPicture());
		
		return linearLayout;
	}

}
